package com.mall4jcola.cloud.auth.executor.query;

import com.alibaba.cola.dto.SingleResponse;
import com.mall4jcola.cloud.auth.gateway.UserAuthsQueryGateway;
import com.mall4jcola.cloud.constant.IdentityTypeEnum;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @author hmxchen
 */
@Component
@AllArgsConstructor
public class SingleAccountQryExe {

    private final UserAuthsQueryGateway userAuthsQueryGateway;

    public SingleResponse<String> execute(String identityType,String identifier) {
        String account = identifier;
        switch (IdentityTypeEnum.convert(identityType)){
            case WETCHAT:
                //解析code,解析出openid并赋值给account
                account = userAuthsQueryGateway.getWxOpenIdByCode(identifier);
                break;
        }
        return SingleResponse.of(account);
    }
}
